using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using ECommerce.Library.Web;
using AutoGear.BLL;

public partial class myaccount_default : SitePublicBasePage
{
    

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (SessionManager.IsUserLoggedIn)
            {
                if (SessionManager.ReturnUrl != null)
                {
                    GenerateSEOData();
                    string returnUrl = SessionManager.ReturnUrl;
                    SessionManager.ReturnUrl = null;
                    Response.Redirect(returnUrl);
                }
                else
                {
                    SetPageTitleAndBreadcramb();
                }
            }
            else
            {
                Response.Redirect(string.IsNullOrEmpty(SupplierId) ? CustomSiteMap.Login : "~/partner/" + SupplierId + "/login.aspx");
            }
        }
    }

    private void SetPageTitleAndBreadcramb()
    {
        ContentPlaceHolder ph = (ContentPlaceHolder)this.Master.Master.FindControl("cphMiddleContent");

        Literal litPageTitle = (Literal)ph.FindControl("litPageTitle");
        Literal litCurrentPage = (Literal)ph.FindControl("litCurrentPage");

        if (litPageTitle != null)
        {
            litCurrentPage.Text = litPageTitle.Text = "User Home Page";

        }
    }

    private void GenerateSEOData()
    {
        //SEOHelper.RenderTitle(this.Page, "My Account :: Traditional Polish foods, steaks, Polish sausages, Polish dumplings, Polish pastries, Polish soups, Polish stews by Polana ", true);
        //SEOHelper.RenderMetaTag(this.Page, "description", "Authentic, traditional Polish sausages, kielbasa, smoked sausages, bacon, blood sausage, steaks, premade dishes, parties, torts, breads, coffees, teas, canned goods, dry goods, recipes and more from Polana.", true);
        //SEOHelper.RenderMetaTag(this.Page, "keywords", "authentic, traditional, kielbasa, buy polish food, order polish food, dumplings, coffee, tea, cookies, chocolates, pastries, torts, soups, stews, European sausage, fresh polish sausage, smoked sausage, polish food, polish recipes, polish hams, polish bacons, fresh sausage, sausages, deli sausage, smoked sausages, blood sausages, headcheese, polish cheese, polish hams, polish blood sausage, polish bacon, wienners", true);
        SEOHelper.RenderMetaTag(this.Page, "robots", "ALL", true);
    }

    protected void lnkbLogout_Click(object sender, EventArgs e)
    {
        SessionManager.LoggedUser = null;
        CookieManager.SetCookieValue(CookieManager.USER_NAME, CookieManager.USER_NAME, DateTime.Now.AddDays(-1));
        CookieManager.SetCookieValue(CookieManager.PASSWORD, CookieManager.PASSWORD, DateTime.Now.AddDays(-1));
        Response.Redirect(string.IsNullOrEmpty(SupplierId) ? CustomSiteMap.Home : "~/partner/" + SupplierId);
    }
}
